public class Solution2303 {
    public double calculateTax(int[][] brackets, int income) {
        double ans=0;
        for (int i=0;i<brackets.length;i++){
            if (income<=brackets[i][0]){
                if (i==0){
                    ans+=income*brackets[0][1];
                }else {
                    ans+=(income-brackets[i-1][0])*brackets[i][1];
                }
                break;
            }else {
                if (i==0){
                    ans+=brackets[0][0]*brackets[0][1];
                }else {
                    ans+=(brackets[i][0]-brackets[i-1][0])*brackets[i][1];
                }
            }
        }
        return ans/100;
    }

    public static void main(String[] args) {
        System.out.println(new Solution2303().calculateTax(new int[][]{{3,50},{7,10},{12,25}},10));
    }
}
